<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
      <script>
        //页面加载
        window.addEventListener("load",function(){
            let btn=document.querySelector(".btn")
            btn.addEventListener("click",function(){
                alert("点击了")
            })
        })
    </script>
</head>
<body>

     <button class="btn">按钮</button>
  
</body>
</html>